// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class RQI_I01 : AbstractMessage
    {
		/// Constructor
		public RQI_I01() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "RQI", TriggerEvent = "I01" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PROVIDER",2)]
  	    [HL7Field(HL7Version.v23, 2, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v231, 2, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v25, 3, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v251, 3, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
  	    [HL7Field(HL7Version.v27, 4, HL7Repeat.True, HL7Required.True,"PROVIDER_RQI_I01")]
	    public PROVIDER_RQI_I01[] PROVIDER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PID",10)]
  	    [HL7Field(HL7Version.v23, 10, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v231, 10, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v24, 10, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v25, 7, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v251, 7, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v26, 8, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v27, 8, HL7Repeat.False, HL7Required.True,"PID")]
	    public PID PID {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("NK1",13)]
  	    [HL7Field(HL7Version.v23, 13, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v231, 13, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v24, 13, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v25, 8, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v251, 8, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v26, 9, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v27, 9, HL7Repeat.True, HL7Required.False,"NK1")]
	    public NK1[] NK1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("GUARANTOR_INSURANCE",16)]
  	    [HL7Field(HL7Version.v23, 16, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v231, 16, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v24, 16, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v25, 9, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v251, 9, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v26, 10, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
  	    [HL7Field(HL7Version.v27, 10, HL7Repeat.False, HL7Required.False,"GUARANTOR_INSURANCE_RQI_I01")]
	    public GUARANTOR_INSURANCE_RQI_I01 GUARANTOR_INSURANCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("NTE",34)]
  	    [HL7Field(HL7Version.v23, 34, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v231, 34, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v24, 34, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v25, 17, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v251, 17, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v26, 18, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v27, 18, HL7Repeat.True, HL7Required.False,"NTE")]
	    public NTE[] NTE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("SFT",2)]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v251, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v27, 2, HL7Repeat.True, HL7Required.False,"SFT")]
	    public SFT[] SFT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("UAC",3)]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.False, HL7Required.False,"UAC")]
  	    [HL7Field(HL7Version.v27, 3, HL7Repeat.False, HL7Required.False,"UAC")]
	    public UAC UAC {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v23 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		}
		if (HL7Version.v231 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		}
		if (HL7Version.v24 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		}
		if (HL7Version.v25 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v251 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v26 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
		if (HL7Version.v27 == options.Version) {
		 PROVIDER = ProcessGroupArray<PROVIDER_RQI_I01>(availableData, options, "PROVIDER");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 GUARANTOR_INSURANCE = ProcessGroup<GUARANTOR_INSURANCE_RQI_I01>(availableData, options, "GUARANTOR_INSURANCE");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "RQI_I01";
			}
        }

        static RQI_I01() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(RQI_I01));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (PROVIDER != null && PROVIDER.Length > 0) {
				for (int i = 0; i < PROVIDER.Length; i++) {
					segmentData.Add(PROVIDER[i].GetER7(options));
				}
			}
			if (PID != null) {
				segmentData.Add(PID.GetER7(options));
			}
			if (NK1 != null && NK1.Length > 0) {
				for (int i = 0; i < NK1.Length; i++) {
					segmentData.Add(NK1[i].GetER7(options));
				}
			}
			if (GUARANTOR_INSURANCE != null) {
				segmentData.Add(GUARANTOR_INSURANCE.GetER7(options));
			}
			if (NTE != null && NTE.Length > 0) {
				for (int i = 0; i < NTE.Length; i++) {
					segmentData.Add(NTE[i].GetER7(options));
				}
			}
			if (SFT != null && SFT.Length > 0) {
				for (int i = 0; i < SFT.Length; i++) {
					segmentData.Add(SFT[i].GetER7(options));
				}
			}
			if (UAC != null) {
				segmentData.Add(UAC.GetER7(options));
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

